const createDepartmentService = () => import("~/service/service-manage/department.service")

export default {
    namespaced: true,
    state: {
        departmentInfo: []
    },
    getters: {},
    mutations: {
        /**
         * 更新组织名称信息
         * @param {*} state
         * @param {*} value
         */
        updateDepartmentInfo(state, value) {
            state.departmentInfo = value
        }
    },
    actions: {
        /**
         * 更新组织名称信息
         */
        async updateDepartment({ state, commit }) {
            let { DepartmentService } = await createDepartmentService()
            DepartmentService.getInstance().getAllDeptList().subscribe(data => {
                commit("updateDepartmentInfo", data)
                // 调用根节点的mutation
                commit("updateDepartment", data, { root: true })
            })
        }
    }
}